package it.gius.pe.mains;

import java.util.concurrent.Semaphore;

import it.gius.pe.Shape.Ellipse;
import it.gius.pe.Shape.witness.Witness;
import it.gius.pe.Shape.witness.PolyPointWitness;
import it.gius.processing.gjkTest.EllipsesDistanceApllet;
import it.gius.processing.util.PAppletManager;
import it.gius.processing.util.ProcessingGraphicException;

import org.jbox2d.common.Vec2;

public class EllipsesDistanceMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		

		Ellipse ellipses[] = new Ellipse[3];
		
		ellipses[0] = new Ellipse(50,25,new Vec2(100,100),
				(float)Math.PI/3);
		
		ellipses[1] = new Ellipse(60,35,new Vec2(200,200),0);
		
		ellipses[2] = new Ellipse(70,20, new Vec2(60,200),(float)(5*Math.PI/4));
		
		Semaphore semaphore = null;
		PAppletManager manager = new PAppletManager(false,true);
		
		EllipsesDistanceApllet applet = new EllipsesDistanceApllet(ellipses);
		
		try {
			semaphore = manager.startAndAddApplet(new String[]{""}, applet, PAppletManager.DISPOSE_ONLY_ME);
		} catch (ProcessingGraphicException e) {
			e.printStackTrace();
			System.exit(1);
		}
		
		try {
			if(semaphore!= null)
				semaphore.acquire();
			
			double mediumEE = applet.getMediumIterationEE();
			double mediumEM = applet.getMediumIterationEM();
			
			System.out.println("Medium number of iteration needed for the distance ellipse ellipse: " + mediumEE);
			System.out.println("Medium number of iteration needed for the distance ellipse mouse: " + mediumEM);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

}
